home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / amos / AMOSList_0197.lzh / AMOSLIST / 000154_amos-request@svcs1.digex.net_Mon Jan 27 11:22:55 1997.msg < prev    next >
Internet Message Format  |  1997-02-02  |  3KB

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
  2.     by mail1.access.digex.net (8.8.5/8.8.5) with ESMTP id LAA17821
  3.     for <mcox@access.digex.net>; Mon, 27 Jan 1997 11:22:25 -0500 (EST)
  4. Received: (from daemon@localhost)
  5.     by svcs1.digex.net (8.8.5/8.8.5) id JAA05830
  6.     for amos-out; Mon, 27 Jan 1997 09:28:37 -0500 (EST)
  7. Received: from mail3.access.digex.net (mail3.access.digex.net [205.197.247.4])
  8.     by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id JAA05827
  9.     for <amos-list@svcs1.digex.net>; Mon, 27 Jan 1997 09:28:36 -0500 (EST)
  10. Received: from nexus.iu.hioslo.no (nexus.iu.hioslo.no [128.39.89.10])
  11.     by mail3.access.digex.net (8.8.5/8.8.5) with ESMTP id JAA11707
  12.     for <amos-list@access.digex.net>; Mon, 27 Jan 1997 09:28:35 -0500 (EST)
  13. Received: from pc.iu.hioslo.no (pc [128.39.89.11]) by nexus.iu.hioslo.no (8.7.1/8.7.1) with ESMTP id PAA26483 for <amos-list@access.digex.net>; Mon, 27 Jan 1997 15:28:32 +0100 (MET)
  14. Received: from OIH2/MAILQUEUE by pc.iu.hioslo.no (Mercury 1.21);
  15.     27 Jan 97 15:36:15 +0100
  16. Received: from MAILQUEUE by OIH2 (Mercury 1.21); 27 Jan 97 15:36:01 +0100
  17. From: "OTTINSEN TOR ERIK/1AC" <TorErik.Ottinsen@iu.hioslo.no>
  18. Organization:  Oslo College
  19. To: amos-list@access.digex.net
  20. Date:          Mon, 27 Jan 1997 15:35:51 GMT+1
  21. MIME-Version:  1.0
  22. Content-type: text/plain; charset=US-ASCII
  23. Content-transfer-encoding: 7BIT
  24. Subject:       Re: goto
  25. Priority: normal
  26. X-mailer: Pegasus Mail v3.31
  27. Message-ID: <1F4D7E406F9@pc.iu.hioslo.no>
  28. Status: RO
  29. X-Status: 
  30.  
  31. >>  gs> Do
  32. >>  gs> Goto Rnd(4)
  33. >>  gs> 0
  34. >> <bla>
  35. >>  gs> 1
  36. >> <bla>
  37. >>  gs> 2
  38. >> <bla>
  39. >>  gs> 3
  40. >> <bla>
  41. >>  gs> 4
  42. >> <bla>
  43. >>  gs> Loop
  44. >
  45. >>  gs> How can I get the program to go to each label
  46. >>  gs> only once?  (randomly)
  47. >
  48. >> I think this is the easiest:
  49. >> dim a(n)
  50. >> for i=1 to n
  51. >> a(i)=i
  52. >> next
  53. >> for i=1 to n
  54. >> r=rnd(n)+1
  55. >> goto r
  56. >> a(r)=a(n)
  57. >> dec n
  58. >> next
  59. >
  60. >I can't follow the logic of that program, but this program will do what was
  61. >originally requested:
  62. >
  63. >Dim a(4)
  64. >
  65. >' Store the label numbers in an array
  66. >For n=0 To 4
  67. >a(n)=n
  68. >Next n
  69. >
  70. >' Shuffle the array about, 25 times
  71. >For time=1 To 25
  72. >Swap a(Rnd(4)),a(Rnd(4))
  73. >Next time
  74.  
  75. A better shuffling algorithm would be this:
  76.  
  77. For n=0 to 4
  78. Swap a(n),a(rnd(5))
  79. Next n
  80.  
  81. >
  82. >' Go to each label in a random order
  83. >For n=0 To 4
  84. >Gosub a(n)
  85. >Next n
  86. >
  87. >0 ... Return
  88. >1 ... Return
  89. >2 ... Return
  90. >3 ... Return
  91. >4 ... Return
  92. >
  93.  
  94.  
  95. ---> ottinst@pc.iu.hioslo.no <---